package com.cxyd.modules.api.dto;

import java.io.Serializable;

public class RcsResultHK implements Serializable {
    private static final long serialVersionUID = 1L;

    // 匹配返回的字段
    private String code;
    private String message;
    private Data data; // 使用具体的Data类而不是Object
    private String errorCode;
    private Boolean success;

    public RcsResultHK error(String robotTaskCode, String message) {
        this.code = "500";
        // 确保data对象不为null
        if (this.data == null) {
            this.data = new Data();
        }
        this.data.setRobotTaskCode(robotTaskCode);
        this.message = message;
        return this;
    }
    public RcsResultHK success(String message) {
        this.code = "SUCCESS";
        this.message = message;
        return this;
    }

    // Data内部类
    public static class Data {
        private String robotTaskCode;

        // Getter和Setter
        public String getRobotTaskCode() {
            return robotTaskCode;
        }

        @Override
        public String toString() {
            return "Data{robotTaskCode='" + robotTaskCode + "'}";
        }

        public void setRobotTaskCode(String robotTaskCode) {
            this.robotTaskCode = robotTaskCode;
        }
    }

    // Getter和Setter方法
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Data getData() {
        return data;
    }

    public void setData(Data data) {
        this.data = data;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    @Override
    public String toString() {
        return "RcsResultHK{" +
                "code='" + code + '\'' +
                ", message='" + message + '\'' +
                ", data=" + (data != null ? data.toString() : "null") +
                ", errorCode='" + errorCode + '\'' +
                ", success=" + success +
                '}';
    }

    // 辅助方法
    public boolean isSuccess() {
        return "SUCCESS".equals(code) || "0".equals(errorCode);
    }

    public String getRobotTaskCode() {
        return data != null ? data.getRobotTaskCode() : null;
    }
}
